var sortedSquares = function(nums) {
    let length=nums.length
    let result=[]

    for(let i=0;i<length;i++){
        result.push(Math.pow(nums[i],2))
    }
    result.sort(function(a,b){
        return a-b
    })
    return result
};

console.log(sortedSquares([-4,-1,0,3,10]));